package leetcode.code1333;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

import leetcode.IDebug;

public class Solution implements IDebug {

	public List<Integer> filterRestaurants(int[][] restaurants, int veganFriendly, int maxPrice, int maxDistance) {
		Arrays.sort(restaurants, (a, b) -> {
			if (a[1] != b[1]) {
				return b[1] - a[1];
			} else {
				return b[0] - a[0];
			}
		});
		int len = restaurants.length;
		List<Integer> ans = new ArrayList<>();
		for (int i = 0; i < len; i++) {
			int[] rest = restaurants[i];
			int idi = rest[0], ratingi = rest[1], veganFriendlyi = rest[2], pricei = rest[3], distancei = rest[4];
			if (pricei <= maxPrice && distancei <= maxDistance) {
				if (veganFriendly == 0 || (veganFriendly == 1 && veganFriendlyi == 1)) {
					ans.add(idi);
				}
			}
		}
		return ans;
	}

	@Override
	public void debug1() {
		// TODO Auto-generated method stub

	}

	@Override
	public void debug2() {
		// TODO Auto-generated method stub

	}

	@Override
	public void debug3() {
		// TODO Auto-generated method stub

	}

	@Override
	public void debug4() {
		// TODO Auto-generated method stub

	}

	public static void main(String[] args) {
		// TODO Auto-generated method stub

	}

}
